package com.example.demo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author leiliang
 * @version 1.0
 * @Description   测试map结构
 * @date 2021/6/4 18:39
 */
public class MapTest {

    public static void main(String[] args) {
        Map<String, List<User>> cache = new HashMap<>();
        List<User> list = new ArrayList<>();
        User user = new User();
        user.setId(2);
        user.setAge(123);
        user.setName("张三");
        list.add(user);
        User user2 = new User();
        user2.setId(1);
        user2.setAge(789);
        user2.setName("李四");
        list.add(user2);
        if (user.getId() == 2) {
            list.remove(user);
        }
        System.out.println(list);

        User user1 = new User();
        user.setId(2);
        user1.setAge(456);
        user1.setName("王五");
        list.add(user1);
        cache.put("1", list);


        Map<String, Object> obj = new HashMap<>();
        List<User> listObj = new ArrayList<>();
        User u = new User();
        u.setId(2);
        u.setAge(123);
        u.setName("张三");
        listObj.add(u);
        obj.put("11", listObj);
        System.out.println(obj);
    }
}
